package com.jsyl.lwbk.business.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsyl.lwbk.business.domain.*;
import com.jsyl.lwbk.business.domain.education.ChildCourse;
import com.jsyl.lwbk.business.dto.*;
import com.jsyl.lwbk.business.mapper.*;
import com.jsyl.lwbk.business.mapper.education.ChildCourseMapper;
import com.jsyl.lwbk.business.mapper.education.CourseChildMapper;
import com.jsyl.lwbk.business.service.CourseChildScoreService;
import com.jsyl.lwbk.common.utils.DateUtils;
import com.jsyl.lwbk.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * @author Fitch
 * 2022/3/28
 */
@Service
public class CourseChildScoreServiceImpl implements CourseChildScoreService {

    @Autowired
    private CourseChildScoreMapper courseChildScoreMapper;
    @Autowired
    private IntegrationMapper integrationMapper;
    @Autowired
    private IntegrationTrainAmountMapper integrationTrainAmountMapper;
    @Autowired
    private ChildProjectConfigMapper childProjectConfigMapper;
    @Autowired
    private CourseChildProjectMapper courseChildProjectMapper;
    @Autowired
    private UnlockRule unlockRule;
    @Autowired
    private ChildCourseMapper childCourseMapper;
    @Autowired
    private CourseChildMapper courseChildMapper;
    @Autowired
    private ChildBasicExpressionMapper childBasicExpressionMapper;


    @Override
    public List<CourseChildScoreDTO> list(Long childCourseId) {
        List<CourseChildScoreDTO> list = this.courseChildScoreMapper.findListByCourse(childCourseId);
        if(CollectionUtils.isEmpty(list)){
            return list;
        }
        //获取项目记录项
        List<Integer> temp =new ArrayList<>();
        temp.add(4);
        temp.add(4);
        List<Integration> integrationList = integrationMapper.findList(temp);
        Map<String,String> integrationNameMap = new HashMap<>();
        Map<String,String> integrationQuestionMap = new HashMap<>();
        for(Integration i:integrationList){
            integrationNameMap.put(i.getCode(),i.getName());
            integrationQuestionMap.put(i.getCode(),i.getQuestions());
        }
        List<IntegrationTrainAmount> integrationTrainAmountList = this.integrationTrainAmountMapper.listByIds(CollectionUtils.arrayToList(list.get(0).getTrainAmountIds().split(",")));
        Map<String,String> trainAmountNameMap = new HashMap<>();
        for(IntegrationTrainAmount it:integrationTrainAmountList){
            trainAmountNameMap.put(it.getId().toString(),it.getTrainContent());
        }
        //获取历史成绩
        Map<String,String> scoreMap = new HashMap<>();
        //当节课填写记录
        List<CourseChildScore> scoreList = this.courseChildScoreMapper.selectList(childCourseId);
        for(CourseChildScore score :scoreList){
            scoreMap.put(score.getChildId()+"-"+score.getProjectCode(),score.getScore());
        }
        if(list.size()>1){
            CourseChildScoreDTO all =new CourseChildScoreDTO();
            all.setChildId(0L);
            all.setChildName("全部学员");
            for(CourseChildScoreDTO dto:list){
                if(all.getLinkOne()==null){ all.setLinkOne(dto.getLinkOne()); }else { all.setLinkOne(all.getLinkOne().equals(dto.getLinkOne())?dto.getLinkOne():""); }
                if(all.getLinkTwo()==null){ all.setLinkTwo(dto.getLinkTwo()); }else { all.setLinkTwo(all.getLinkTwo().equals(dto.getLinkTwo())?dto.getLinkTwo():""); }
                if(all.getLinkThree()==null){ all.setLinkThree(dto.getLinkThree()); }else { all.setLinkThree(all.getLinkThree().equals(dto.getLinkThree())?dto.getLinkThree():""); }
                if(all.getLinkFour()==null){ all.setLinkFour(dto.getLinkFour()); }else { all.setLinkFour(all.getLinkFour().equals(dto.getLinkFour())?dto.getLinkFour():""); }
                if(all.getLinkFive()==null){ all.setLinkFive(dto.getLinkFive()); }else { all.setLinkFive(all.getLinkFive().equals(dto.getLinkFive())?dto.getLinkFive():""); }
                if(all.getLinkSix()==null){ all.setLinkSix(dto.getLinkSix()); }else { all.setLinkSix(all.getLinkSix().equals(dto.getLinkSix())?dto.getLinkSix():""); }
                if(all.getLinkSeven()==null){ all.setLinkSeven(dto.getLinkSeven()); }else { all.setLinkSeven(all.getLinkSeven().equals(dto.getLinkSeven())?dto.getLinkSeven():""); }
                if(all.getLinkEight()==null){ all.setLinkEight(dto.getLinkEight()); }else { all.setLinkEight(all.getLinkEight().equals(dto.getLinkEight())?dto.getLinkEight():""); }
                if(all.getLinkNine()==null){ all.setLinkNine(dto.getLinkNine()); }else { all.setLinkNine(all.getLinkNine().equals(dto.getLinkNine())?dto.getLinkNine():""); }
            }
            list.add(0,all);
        }
        for(CourseChildScoreDTO dto:list){
            dto.setLinkOneQuestion(integrationQuestionMap.get(dto.getLinkOne()));
            dto.setLinkTwoQuestion(integrationQuestionMap.get(dto.getLinkTwo()));
            dto.setLinkThreeQuestion(integrationQuestionMap.get(dto.getLinkThree()));
            dto.setLinkFourQuestion(integrationQuestionMap.get(dto.getLinkFour()));
            if(!dto.getLinkFive().equals(dto.getLinkFour())){
                dto.setLinkFiveQuestion(integrationQuestionMap.get(dto.getLinkFive()));
            }
            dto.setLinkSixQuestion(integrationQuestionMap.get(dto.getLinkSix()));
            dto.setLinkSevenQuestion(integrationQuestionMap.get(dto.getLinkSeven()));
            dto.setLinkEightQuestion(integrationQuestionMap.get(dto.getLinkEight()));
            dto.setLinkNineQuestion(integrationQuestionMap.get(dto.getLinkNine()));

            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkOne())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkOne());
            }
            dto.setLinkOneScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkOne()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkTwo())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkTwo());
            }
            dto.setLinkTwoScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkTwo()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkThree())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkThree());
            }
            dto.setLinkThreeScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkThree()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkFour())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkFour());
            }
            dto.setLinkFourScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkFour()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkFive())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkFive());
            }
            dto.setLinkFiveScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkFive()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkSix())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkSix());
            }
            dto.setLinkSixScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkSix()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkSeven())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkSeven());
            }
            dto.setLinkSevenScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkSeven()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkEight())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkEight());
            }
            dto.setLinkEightScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkEight()));
            if(!scoreMap.containsKey(dto.getChildId()+"-"+dto.getLinkNine())){
                scoreMap=getLastScore(scoreMap,childCourseId,dto.getChildId(),dto.getLinkNine());
            }
            dto.setLinkNineScore(scoreMap.get(dto.getChildId()+"-"+dto.getLinkNine()));

            dto.setLinkOne(integrationNameMap.get(dto.getLinkOne())+ (StringUtils.isEmpty(dto.getTrainAmountOne())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountOne())));
            dto.setLinkTwo(integrationNameMap.get(dto.getLinkTwo())+(StringUtils.isEmpty(dto.getTrainAmountTwo())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountTwo())));
            dto.setLinkThree(integrationNameMap.get(dto.getLinkThree())+(StringUtils.isEmpty(dto.getTrainAmountThree())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountThree())));
            dto.setLinkFour(integrationNameMap.get(dto.getLinkFour())+(StringUtils.isEmpty(dto.getTrainAmountFour())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountFour())));
            dto.setLinkFive(integrationNameMap.get(dto.getLinkFive())+(StringUtils.isEmpty(dto.getTrainAmountFive())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountFive())));
            dto.setLinkSix(integrationNameMap.get(dto.getLinkSix())+(StringUtils.isEmpty(dto.getTrainAmountSix())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountSix())));
            dto.setLinkSeven(integrationNameMap.get(dto.getLinkSeven())+(StringUtils.isEmpty(dto.getTrainAmountSeven())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountSeven())));
            dto.setLinkEight(integrationNameMap.get(dto.getLinkEight())+(StringUtils.isEmpty(dto.getTrainAmountEight())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountEight())));
            dto.setLinkNine(integrationNameMap.get(dto.getLinkNine())+(StringUtils.isEmpty(dto.getTrainAmountNine())?"":"/"+trainAmountNameMap.get(dto.getTrainAmountNine())));
        }
        return list;
    }

    private Map getLastScore(Map map,Long childCourseId,Long childId,String projectCode){
        CourseChildScore score = this.courseChildScoreMapper.getLastScore(childCourseId,childId,projectCode);
        if(score !=null){
            map.put(score.getChildId()+"-"+score.getProjectCode(),score.getScore());
        }
        return map;
    }
    @Override
    public void saveScore(SaveScoreDTO saveScoreDTO) {
        if(saveScoreDTO!=null && !CollectionUtils.isEmpty(saveScoreDTO.getScoreList())){
            for(SaveScoreDetailDTO dto:saveScoreDTO.getScoreList()){
                CourseChildProject project = courseChildProjectMapper.selectOne(saveScoreDTO.getChildCourseId(),dto.getChildId());
                if(project ==null){
                    continue;
                }
                if(!StringUtils.isEmpty(project.getLinkOne()) && !StringUtils.isEmpty(dto.getLinkOneScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkOne(),dto.getLinkOneScore());
                }
                if(!StringUtils.isEmpty(project.getLinkTwo()) && !StringUtils.isEmpty(dto.getLinkTwoScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkTwo(),dto.getLinkTwoScore());
                }
                if(!StringUtils.isEmpty(project.getLinkThree()) && !StringUtils.isEmpty(dto.getLinkThreeScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkThree(),dto.getLinkThreeScore());
                }
                if(!StringUtils.isEmpty(project.getLinkFour()) && !StringUtils.isEmpty(dto.getLinkFourScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkFour(),dto.getLinkFourScore());
                }
                if(!StringUtils.isEmpty(project.getLinkFive()) && !StringUtils.isEmpty(dto.getLinkFiveScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkFive(),dto.getLinkFiveScore());
                }
                if(!StringUtils.isEmpty(project.getLinkSix()) && !StringUtils.isEmpty(dto.getLinkSixScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkSix(),dto.getLinkSixScore());
                }
                if(!StringUtils.isEmpty(project.getLinkSeven()) && !StringUtils.isEmpty(dto.getLinkSevenScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkSeven(),dto.getLinkSevenScore());
                }
                if(!StringUtils.isEmpty(project.getLinkEight()) && !StringUtils.isEmpty(dto.getLinkEightScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkEight(),dto.getLinkEightScore());
                }
                if(!StringUtils.isEmpty(project.getLinkNine()) && !StringUtils.isEmpty(dto.getLinkNineScore())){
                    saveScore(saveScoreDTO,dto.getChildId(),project.getLinkNine(),dto.getLinkNineScore());
                }
            }
            ChildCourse childCourse= childCourseMapper.selectById(saveScoreDTO.getChildCourseId());
            if(childCourse!=null && saveScoreDTO.getScoreFlag().equals(1) &&
                    (childCourse.getScoreFlag() ==null||childCourse.getScoreFlag().equals(0))){
                this.childCourseMapper.updateScoreFlag(saveScoreDTO.getChildCourseId());
                this.courseChildMapper.updateScoreFlag(saveScoreDTO.getChildCourseId());
            }
        }

    }

    @Override
    public void saveReadingComprehensionScore(SaveReadingScoreDTO dto) {
        if(dto!=null && dto.getScoreList().size()>0){
            for(Map map:dto.getScoreList()){
                Long childId =Long.valueOf(map.get("childId").toString());
                map.remove("childId");
                CourseChildScore score=this.courseChildScoreMapper.selectScore(dto.getChildCourseId(),childId,null);
                if(score==null){
                    score = new CourseChildScore();
                    score.setChildCourseId(dto.getChildCourseId());
                    score.setChildId(childId);
                    score.setCreateUser(dto.getUpdateUser());
                    score.setCreateTime(DateUtils.getNowDate());
                    score.setScore(JSON.toJSONString(map));
                    this.courseChildScoreMapper.insert(score);
                }else {
                    score.setUpdateUser(dto.getUpdateUser());
                    score.setUpdateTime(DateUtils.getNowDate());
                    score.setScore(JSON.toJSONString(map));
                    this.courseChildScoreMapper.update(score);
                }


            }
            if(dto.getSubmitFlag().equals(1)){
                this.childCourseMapper.updateScoreFlag(dto.getChildCourseId());
            }

        }

    }

    private void saveScore(SaveScoreDTO saveScoreDTO, Long childId, String projectCode, String scoreStr) {
        CourseChildScore score = this.courseChildScoreMapper.selectScore(saveScoreDTO.getChildCourseId(),childId,projectCode);
        if(score ==null){
            score =new CourseChildScore();
            score.setChildCourseId(saveScoreDTO.getChildCourseId());
            score.setChildId(childId);
            score.setProjectCode(projectCode);
            score.setScore(scoreStr);
            score.setCreateUser(saveScoreDTO.getUpdateUser());
            score.setCreateTime(DateUtils.getNowDate());
            score.setUpdateUser(saveScoreDTO.getUpdateUser());
            score.setUpdateTime(DateUtils.getNowDate());
            this.courseChildScoreMapper.insert(score);
        }else {
            score.setScore(scoreStr);
            score.setUpdateUser(saveScoreDTO.getUpdateUser());
            score.setUpdateTime(DateUtils.getNowDate());
            this.courseChildScoreMapper.update(score);
        }
        if(saveScoreDTO.getScoreFlag().equals(1)){
            //增加完成次数
            ChildProjectConfig config = this.childProjectConfigMapper.selectOne(childId,projectCode);
            if(config!=null){
                config.setCompleteTimes(config.getCompleteTimes()+1);
                this.childProjectConfigMapper.update(config);
            }
            // 调用解锁
            this.unlockRule.unlock(childId,saveScoreDTO.getChildCourseId(),projectCode,scoreStr);
        }
    }

    @Override
    public void saveBasicExpression(SaveBasicExpressionDTO dto) {
        CourseChildScore score = this.courseChildScoreMapper.selectScore(dto.getChildCourseId(),dto.getChildId(),"BasicExpression");
        if(score ==null){
            score =new CourseChildScore();
            score.setBasicExpression(dto.getBasicExpression());
            score.setChildCourseId(dto.getChildCourseId());
            score.setChildId(dto.getChildId());
            score.setProjectCode("BasicExpression");
            score.setCreateUser(dto.getUpdateUser());
            score.setCreateTime(DateUtils.getNowDate());
            score.setUpdateUser(dto.getUpdateUser());
            score.setUpdateTime(DateUtils.getNowDate());
            this.courseChildScoreMapper.insert(score);
        }else {
            score.setBasicExpression(dto.getBasicExpression());
            score.setUpdateUser(dto.getUpdateUser());
            score.setUpdateTime(DateUtils.getNowDate());
            this.courseChildScoreMapper.update(score);
        }
        List<ChildBasicExpression> basicExpressionList = this.childBasicExpressionMapper.selectList(dto.getChildId());
        JSONObject object = JSONObject.parseObject(dto.getBasicExpression());
        Iterator iter = object.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            ChildBasicExpression local =null;
            for(ChildBasicExpression basic:basicExpressionList){
                if(basic.getBasicDesc().equals(entry.getKey())){
                    local = basic;
                    if(basic.getBasicDesc().equals("speed")){
                        String currentValue = (entry.getValue()==null?"":entry.getValue().toString());
                        JSONArray newlList =new JSONArray();
                        if(StringUtils.isNotEmpty(local.getBasicExpression())){
                            JSONArray localList =JSONArray.parseArray(local.getBasicExpression());
                            for(Object s:localList){
                                JSONObject json = JSONObject.parseObject(s.toString());
                                if(!currentValue.equals(json.get("value"))){
                                    json.put("checked","false");
                                    newlList.add(json);
                                }else {
                                    if("false".equals(json.get("checked"))){
                                        newlList.add(json);
                                    }else {
                                        currentValue="";
                                        newlList.add(json);
                                    }

                                }
                            }
                            if(StringUtils.isNotEmpty(currentValue)){
                                JSONObject temp =new JSONObject();
                                temp.put("value",currentValue);
                                temp.put("checked","true");
                                newlList.add(temp);
                            }
                        }else {
                            if(StringUtils.isNotEmpty(currentValue)){
                                JSONObject temp =new JSONObject();
                                temp.put("value",currentValue);
                                temp.put("checked","true");
                                newlList.add(temp);
                            }

                        }
                        local.setBasicExpression(newlList.toJSONString());
                    }else {
                        JSONArray currentCheck=(entry.getValue()==null?new JSONArray():JSONArray.parseArray(entry.getValue().toString()));
                        JSONArray newlList =new JSONArray();
                        if(StringUtils.isNotEmpty(local.getBasicExpression())){
                            JSONArray localList =JSONArray.parseArray(local.getBasicExpression());
                            for(Object s:localList){
                                JSONObject json = JSONObject.parseObject(s.toString());
                                if(!currentCheck.contains(json.get("value"))){
                                    json.put("checked","false");
                                    newlList.add(json);
                                }else {
                                    if("false".equals(json.get("checked"))){
                                        newlList.add(json);
                                    }else {
                                        newlList.add(json);
                                        currentCheck.remove(json.get("value"));
                                    }
                                }
                            }
                            for(Object o:currentCheck){
                                JSONObject temp =new JSONObject();
                                temp.put("value",o.toString());
                                temp.put("checked","true");
                                newlList.add(temp);
                            }
                        }else {
                            for(Object o:currentCheck){
                                JSONObject temp =new JSONObject();
                                temp.put("value",o.toString());
                                temp.put("checked","true");
                                newlList.add(temp);
                            }
                        }
                        local.setBasicExpression(newlList.toJSONString());

                    }

                    this.childBasicExpressionMapper.update(local);
                    break;
                }
            }
            //不存在记录时，新增
            if(local == null){
                local =new ChildBasicExpression();
                local.setChildId(dto.getChildId());
                local.setBasicDesc(entry.getKey().toString());
                if(local.getBasicDesc().equals("speed")){
                    List<Object> list =new ArrayList<>();
                    if(StringUtils.isNotEmpty(StringUtils.getString(entry.getValue()))){
                        JSONObject temp =new JSONObject();
                        temp.put("value",StringUtils.getString(entry.getValue()));
                        temp.put("checked","true");
                        list.add(temp);
                        local.setBasicExpression(list.toString());
                    }

                }else {
                    JSONArray  valueList = JSONArray.parseArray(StringUtils.getString(entry.getValue()));
                    List<Object> list =new ArrayList<>();
                    if(valueList !=null){
                        for(Object s:valueList){
                            JSONObject temp =new JSONObject();
                            temp.put("value",s.toString());
                            temp.put("checked","true");
                            list.add(temp);
                        }
                        local.setBasicExpression(list.toString());
                    }
                }

                local.setStatus(0);
                local.setCreateTime(DateUtils.getNowDate());
                this.childBasicExpressionMapper.insert(local);
            }
        }

    }


    @Override
    public void saveChildBasicExpression(SaveBasicExpressionDTO dto) {
        List<ChildBasicExpression> basicExpressionList = this.childBasicExpressionMapper.selectList(dto.getChildId());
        JSONObject object = JSONObject.parseObject(dto.getBasicExpression());
        Iterator iter = object.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            if(entry.getValue().toString().equals("<p><br></p>")){
                continue;
            }
            ChildBasicExpression local =null;
            for(ChildBasicExpression basic:basicExpressionList){
                if(basic.getBasicDesc().equals(entry.getKey())){
                    local = basic;
                    local.setBasicExpression(entry.getValue().toString());
                    this.childBasicExpressionMapper.update(local);
                    break;
                }
            }
            //不存在记录时，新增
            if(local == null){
                local =new ChildBasicExpression();
                local.setChildId(dto.getChildId());
                local.setBasicDesc(entry.getKey().toString());
                local.setBasicExpression(entry.getValue().toString());
                local.setStatus(0);
                local.setCreateTime(DateUtils.getNowDate());
                this.childBasicExpressionMapper.insert(local);
            }
        }
    }

    @Override
    public BasicExpressionDTO getBasicExpression(Long childCourseId, Long childId) {
        BasicExpressionDTO dto =new BasicExpressionDTO();
        List<ChildBasicExpression> list= this.childBasicExpressionMapper.selectList(childId);
//        JSONObject result =new JSONObject();
//        for(ChildBasicExpression basicExpression:list){
//            List<String> tempList =new ArrayList<>();
//            if(StringUtils.isNotEmpty(basicExpression.getBasicExpression())){
//                JSONArray objects = JSONArray.parseArray(basicExpression.getBasicExpression());
//                for(Object s:objects){
//                    JSONObject temp =JSONObject.parseObject(s.toString());
//                    if(StringUtils.getString(temp.get("checked")).equals("true")){
//                        tempList.add(StringUtils.getString(temp.get("value")));
//                    }
//                }
//            }
//            result.put(basicExpression.getBasicDesc(),tempList);
//        }
        dto.setOldRecords(list);
//        dto.setBasicExpression(result.toJSONString());
        return dto;
    }

    @Override
    public List<BasicExpressionDTO> listBasicExpression(Long childCourseId,Long childId) {
        return this.courseChildScoreMapper.listBasicExpression(childCourseId,childId);
    }

    @Override
    public List<ChildScoreDTO> listAllChild(ChildScoreDTO dto) {
        return this.courseChildScoreMapper.listAllChild(dto.getTeacherName(),dto.getChildName(),dto.getPhone(),dto.getTeacherId(),dto.getCenterId());
    }

    @Override
    public List<ChildScoreDetailDTO> childScoreDetailList(Long childId, String teacherName,String startDate,String endDate) {
        List<ChildScoreDetailDTO> list = this.courseChildScoreMapper.childScoreDetailList(childId,teacherName,startDate,endDate);
        return list;
    }

    @Override
    public List<HistoryScoreDTO> listHistoryScore(Long childId, String projectCode) {
        return this.courseChildScoreMapper.listHistoryScore(childId,projectCode);
    }

    @Override
    public List<ReadingComprehensionScoreDTO> listChildScore(Long childCourseId) {
        return this.courseChildScoreMapper.listChildScore(childCourseId);
    }
}
